home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Exchange
/
CD Exchange - Volume 1.iso
/
graphics
/
utils
/
ham8-jpeg
/
source
/
display24.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-12-20
|
19KB
|
948 lines
/*
* display24.c Michael Saunby M.Saunby@reading.ac.uk
*
* Release 1.1
*
* Display 24 bit RGB data using the Albert HAM8 screen.
*/
#include <exec/memory.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <intuition/intuition.h>
#include <graphics/gfxbase.h>
#include <graphics/displayinfo.h>
#include <intuition/screens.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/graphics_protos.h>
#include <stdlib.h>
#include "display24.h"
/*
* Change USE_STD_COLOURS to 0 for ham only. Faster but not as sharp.
* More code could be disabled for greater speed.
*/
#define USE_STD_COLOURS 1
typedef UBYTE std_pal_type;
static ULONG red_dist[9], green_dist[9], blue_dist[9];
static UWORD standard_pens[48];
/*
* The following defines set the standard palette colours.
* The __inline functions are used to compare these colours with the input
* colour.
*
* Greys
*/
#define STD_COLOUR_01 {0,0,0}
static __inline ULONG
dist_fn_01 ()
{
return (red_dist[0] + green_dist[0] + blue_dist[0]);
}
#define STD_COLOUR_02 {32,32,32}
static __inline ULONG
dist_fn_02 ()
{
return (red_dist[1] + green_dist[1] + blue_dist[1]);
}
#define STD_COLOUR_03 {64,64,64}
static __inline ULONG
dist_fn_03 ()
{
return (red_dist[2] + green_dist[2] + blue_dist[2]);
}
#define STD_COLOUR_04 {96,96,96}
static __inline ULONG
dist_fn_04 ()
{
return (red_dist[3] + green_dist[3] + blue_dist[3]);
}
#define STD_COLOUR_05 {128,128,128}
static __inline ULONG
dist_fn_05 ()
{
return (red_dist[4] + green_dist[4] + blue_dist[4]);
}
#define STD_COLOUR_06 {160,160,160}
static __inline ULONG
dist_fn_06 ()
{
return (red_dist[5] + green_dist[5] + blue_dist[5]);
}
#define STD_COLOUR_07 {192,192,192}
static __inline ULONG
dist_fn_07 ()
{
return (red_dist[6] + green_dist[6] + blue_dist[6]);
}
#define STD_COLOUR_08 {224,224,224}
static __inline ULONG
dist_fn_08 ()
{
return (red_dist[7] + green_dist[7] + blue_dist[7]);
}
#define STD_COLOUR_09 {255,255,255}
static __inline ULONG
dist_fn_09 ()
{
return (red_dist[8] + green_dist[8] + blue_dist[8]);
}
/*
* reds
*/
#define STD_COLOUR_10 {64,0,0}
static __inline ULONG
dist_fn_10 ()
{
return (red_dist[2] + green_dist[0] + blue_dist[0]);
}
#define STD_COLOUR_11 {128,0,0}
static __inline ULONG
dist_fn_11 ()
{
return (red_dist[4] + green_dist[0] + blue_dist[0]);
}
#define STD_COLOUR_12 {192,0,0}
static __inline ULONG
dist_fn_12 ()
{
return (red_dist[6] + green_dist[0] + blue_dist[0]);
}
#define STD_COLOUR_13 {255,0,0}
static __inline ULONG
dist_fn_13 ()
{
return (red_dist[8] + green_dist[0] + blue_dist[0]);
}
/*
* greens
*/
#define STD_COLOUR_14 {0,64,0}
static __inline ULONG
dist_fn_14 ()
{
return (red_dist[0] + green_dist[2] + blue_dist[0]);
}
#define STD_COLOUR_15 {0,128,0}
static __inline ULONG
dist_fn_15 ()
{
return (red_dist[0] + green_dist[4] + blue_dist[0]);
}
#define STD_COLOUR_16 {0,192,0}
static __inline ULONG
dist_fn_16 ()
{
return (red_dist[0] + green_dist[6] + blue_dist[0]);
}
#define STD_COLOUR_17 {0,255,0}
static __inline ULONG
dist_fn_17 ()
{
return (red_dist[0] + green_dist[8] + blue_dist[0]);
}
/*
* blues
*/
#define STD_COLOUR_18 {0,0,64}
static __inline ULONG
dist_fn_18 ()
{
return (red_dist[0] + green_dist[0] + blue_dist[2]);
}
#define STD_COLOUR_19 {0,0,128}
static __inline ULONG
dist_fn_19 ()
{
return (red_dist[0] + green_dist[0] + blue_dist[4]);
}
#define STD_COLOUR_20 {0,0,192}
static __inline ULONG
dist_fn_20 ()
{
return (red_dist[0] + green_dist[0] + blue_dist[6]);
}
#define STD_COLOUR_21 {0,0,255}
static __inline ULONG
dist_fn_21 ()
{
return (red_dist[0] + green_dist[0] + blue_dist[8]);
}
/*
* red-greens
*/
#define STD_COLOUR_22 {255,64,0}
static __inline ULONG
dist_fn_22 ()
{
return (red_dist[8] + green_dist[2] + blue_dist[0]);
}
#define STD_COLOUR_23 {255,128,0}
static __inline ULONG
dist_fn_23 ()
{
return (red_dist[8] + green_dist[4] + blue_dist[0]);
}
#define STD_COLOUR_24 {255,192,0}
static __inline ULONG
dist_fn_24 ()
{
return (red_dist[8] + green_dist[6] + blue_dist[0]);
}
#define STD_COLOUR_25 {255,255,0}
static __inline ULONG
dist_fn_25 ()
{
return (red_dist[8] + green_dist[8] + blue_dist[0]);
}
/*
* red-blues
*/
#define STD_COLOUR_26 {255,0,64}
static __inline ULONG
dist_fn_26 ()
{
return (red_dist[8] + green_dist[0] + blue_dist[2]);
}
#define STD_COLOUR_27 {255,0,128}
static __inline ULONG
dist_fn_27 ()
{
return (red_dist[8] + green_dist[0] + blue_dist[4]);
}
#define STD_COLOUR_28 {255,0,192}
static __inline ULONG
dist_fn_28 ()
{
return (red_dist[8] + green_dist[0] + blue_dist[6]);
}
#define STD_COLOUR_29 {255,0,255}
static __inline ULONG
dist_fn_29 ()
{
return (red_dist[8] + green_dist[0] + blue_dist[8]);
}
/*
* green-reds
*/
#define STD_COLOUR_30 {64,255,0}
static __inline ULONG
dist_fn_30 ()
{
return (red_dist[2] + green_dist[8] + blue_dist[0]);
}
#define STD_COLOUR_31 {128,255,0}
static __inline ULONG
dist_fn_31 ()
{
return (red_dist[4] + green_dist[8] + blue_dist[0]);
}
#define STD_COLOUR_32 {192,255,0}
static __inline ULONG
dist_fn_32 ()
{
return (red_dist[6] + green_dist[8] + blue_dist[0]);
}
/*
* green-blues
*/
#define STD_COLOUR_33 {0,255,64}
static __inline ULONG
dist_fn_33 ()
{
return (red_dist[0] + green_dist[8] + blue_dist[2]);
}
#define STD_COLOUR_34 {0,255,128}
static __inline ULONG
dist_fn_34 ()
{
return (red_dist[0] + green_dist[8] + blue_dist[4]);
}
#define STD_COLOUR_35 {0,255,192}
static __inline ULONG
dist_fn_35 ()
{
return (red_dist[0] + green_dist[8] + blue_dist[6]);
}
#define STD_COLOUR_36 {0,255,255}
static __inline ULONG
dist_fn_36 ()
{
return (red_dist[0] + green_dist[8] + blue_dist[8]);
}
/*
* blue-reds
*/
#define STD_COLOUR_37 {64,255,0}
static __inline ULONG
dist_fn_37 ()
{
return (red_dist[2] + green_dist[8] + blue_dist[0]);
}
#define STD_COLOUR_38 {128,255,0}
static __inline ULONG
dist_fn_38 ()
{
return (red_dist[4] + green_dist[8] + blue_dist[0]);
}
#define STD_COLOUR_39 {192,255,0}
static __inline ULONG
dist_fn_39 ()
{
return (red_dist[6] + green_dist[8] + blue_dist[0]);
}
/*
* blue-greens
*/
#define STD_COLOUR_40 {0,64,255}
static __inline ULONG
dist_fn_40 ()
{
return (red_dist[0] + green_dist[2] + blue_dist[8]);
}
#define STD_COLOUR_41 {0,128,255}
static __inline ULONG
dist_fn_41 ()
{
return (red_dist[0] + green_dist[4] + blue_dist[8]);
}
#define STD_COLOUR_42 {0,192,255}
static __inline ULONG
dist_fn_42 ()
{
return (red_dist[0] + green_dist[6] + blue_dist[8]);
}
/*
* red green blue
*/
#define STD_COLOUR_43 {255,255,64}
static __inline ULONG
dist_fn_43 ()
{
return (red_dist[8] + green_dist[8] + blue_dist[2]);
}
#define STD_COLOUR_44 {255,255,128}
static __inline ULONG
dist_fn_44 ()
{
return (red_dist[8] + green_dist[8] + blue_dist[4]);
}
/*
* red blue green
*/
#define STD_COLOUR_45 {255,64,255}
static __inline ULONG
dist_fn_45 ()
{
return (red_dist[8] + green_dist[2] + blue_dist[8]);
}
#define STD_COLOUR_46 {255,128,255}
static __inline ULONG
dist_fn_46 ()
{
return (red_dist[8] + green_dist[4] + blue_dist[8]);
}
/*
* green blue red
*/
#define STD_COLOUR_47 {64,255,255}
static __inline ULONG
dist_fn_47 ()
{
return (red_dist[2] + green_dist[8] + blue_dist[8]);
}
#define STD_COLOUR_48 {128,255,255}
static __inline ULONG
dist_fn_48 ()
{
return (red_dist[4] + green_dist[8] + blue_dist[8]);
}
static std_pal_type standard_palette[48][3] =
{
STD_COLOUR_01, STD_COLOUR_02, STD_COLOUR_03, STD_COLOUR_04, STD_COLOUR_05,
STD_COLOUR_06, STD_COLOUR_07, STD_COLOUR_08, STD_COLOUR_09, STD_COLOUR_10,
STD_COLOUR_11, STD_COLOUR_12, STD_COLOUR_13, STD_COLOUR_14, STD_COLOUR_15,
STD_COLOUR_16, STD_COLOUR_17, STD_COLOUR_18, STD_COLOUR_19, STD_COLOUR_20,
STD_COLOUR_21, STD_COLOUR_22, STD_COLOUR_23, STD_COLOUR_24, STD_COLOUR_25,
STD_COLOUR_26, STD_COLOUR_27, STD_COLOUR_28, STD_COLOUR_29, STD_COLOUR_30,
STD_COLOUR_31, STD_COLOUR_32, STD_COLOUR_33, STD_COLOUR_34, STD_COLOUR_35,
STD_COLOUR_36, STD_COLOUR_37, STD_COLOUR_38, STD_COLOUR_39, STD_COLOUR_40,
STD_COLOUR_41, STD_COLOUR_42, STD_COLOUR_43, STD_COLOUR_44, STD_COLOUR_45,